# -*- coding: utf-8 -*-
# @Author : zhaochen
# @Date   : 2019/8/5
# @File   : IC27_DataIsNull.py
# @E-mail : zhaochen@bbdservice.com



'''eof
name:个人征信数据是否异常
code:IC27_DataIsNull
tableName:
columnName:
groups:个人征信模块
dependencies:IC_DSJ
type:常用指标
datasourceType:在线指标
description:
eof'''

import sys


reload(sys)
sys.setdefaultencoding('utf-8')

null_type_list = ['', ' ', None, 'null', 'Null', 'NULL', '/', '-', '--']

def getTable(table_Name):
    try:
        data = IC_DSJ['data'].get(table_Name)
        if data in null_type_list:
            return None
        else:
            if isinstance(data, list):
                return data
            else:
                return None
    except:
        return None

def IC27_DataIsNull():
    '''判断QueryReq 表中 reportNo  是否缺失'''

    try:
        QueryReq = getTable('QueryReq')
        if QueryReq is None:
            raise Exception(u'个人征信数据reportNo不存在')
        else:
            if QueryReq[0].get('reportNo') in null_type_list:
                raise Exception(u'个人征信数据reportNo不存在')
            else:
                return 0
    except:
        raise Exception(u'个人征信数据reportNo不存在')


result = IC27_DataIsNull()


